//
//  ActivityListTableViewCell.m
//  newDouban
//
//  Created by dllo on 15/10/10.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "ActivityListTableViewCell.h"
#import "UIImageView+WebCache.h"
@interface ActivityListTableViewCell ()

@property (nonatomic, retain) UILabel *title;
@property (nonatomic, retain) UILabel *time;
@property (nonatomic, retain) UILabel *owner;
@property (nonatomic, retain) UILabel *category;
@property (nonatomic, retain) UILabel *address;

@property (nonatomic, retain) UIImageView *backgroundImagVbig;
@property (nonatomic, retain) UIImageView *backgroundImagVsmall;
@property (nonatomic, retain) UIImageView *activityImageV;
@property (nonatomic, retain) UIImageView *titleImageV;
@property (nonatomic, retain) UIImageView *timeImageV;
@property (nonatomic, retain) UIImageView *ownerImageV;
@property (nonatomic, retain) UIImageView *categoryImageV;
@property (nonatomic, retain) UIImageView *addressImageV;

@property (nonatomic, retain) UILabel *interested;
@property (nonatomic, retain) UILabel *interestedL;
@property (nonatomic, retain) UILabel *attend;
@property (nonatomic, retain) UILabel *attendL;



@end


@implementation ActivityListTableViewCell

- (void)dealloc
{
    [_activity release];
    [_title release];
    [_time release];
    [_owner release];
    [_category release];
    [_address release];
    [_backgroundImagVbig release];
    [_backgroundImagVsmall release];
    [_activityImageV release];
    [_titleImageV release];
    [_timeImageV release];
    [_ownerImageV release];
    [_categoryImageV release];
    [_addressImageV release];
    [_interested release];
    [_interestedL release];
    [_attend release];
    [_attendL release];
    
    [super dealloc];
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubviews];
    }
    
    return self;
}

- (void)createSubviews
{
    self.backgroundColor = [UIColor whiteColor];
    //   注意:   6 plus 长宽(点): 414 * 736
    //最低的白色背景图片
    self.backgroundImagVbig = [[UIImageView alloc] initWithFrame:CGRectMake(self.frame.origin.x + 10 , self.frame.origin.y + 10, 394 , 220 - 20)];
    self.backgroundImagVbig.image = [UIImage imageNamed:@"bg_eventlistcell@2x.png"];
    [self.contentView addSubview:self.backgroundImagVbig];
   
    //主题
    self.title = [[UILabel alloc] initWithFrame:CGRectMake(self.backgroundImagVbig.frame.origin.x + 10, self.backgroundImagVbig.frame.origin.y + 5, 414 - 2 * (self.backgroundImagVbig.frame.origin.x + 10), 30)];
    //self.title.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.title];
    [_title release];
    
    //相对小点的白色的背景图片
    self.backgroundImagVsmall = [[UIImageView alloc] initWithFrame:CGRectMake(self.backgroundImagVbig.frame.origin.x + 5, self.title.frame.origin.y + self.title.frame.size.height + 5, self.backgroundImagVbig.frame.size.width - 2 * 5 , self.backgroundImagVbig.frame.size.height - (self.title.frame.size.height + 10) - 5)];//155
    self.backgroundImagVsmall.image = [UIImage imageNamed:@"bg_share_large@2x.png"];
    [self.contentView addSubview:self.backgroundImagVsmall];
    
    
    //时间图片
    self.timeImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.backgroundImagVsmall.frame.origin.x + 5, self.backgroundImagVsmall.frame.origin.y + 5, 25, 25)];
    self.timeImageV.image = [UIImage imageNamed:@"icon_date@2x.png"];
    [self.contentView addSubview:self.timeImageV];
    [_timeImageV release];
    
    //时间显示label
    self.time = [[UILabel alloc] initWithFrame:CGRectMake(self.timeImageV.frame.origin.x + self.timeImageV.frame.size.width + 5, self.backgroundImagVsmall.frame.origin.y + 5, 230, 25)];
    //self.time.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.time];
    [_time release];
    
    //地址图片
    self.addressImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.backgroundImagVsmall.frame.origin.x + 5, self.timeImageV.frame.origin.y + 5 + self.timeImageV.frame.size.height, 25, 25)];
    self.addressImageV.image = [UIImage imageNamed:@"icon_spot@2x.png"];
    [self.contentView addSubview:self.addressImageV];
    [_addressImageV release];
    
    //地址显示lable
    self.address = [[UILabel alloc] initWithFrame:CGRectMake(self.addressImageV.frame.origin.x + self.addressImageV.frame.size.width + 5, self.timeImageV.frame.origin.y + 5 + 25, 230, 25)];
    //self.address.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.address];
    [_address release];
    
    //类型图片
    self.categoryImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.backgroundImagVsmall.frame.origin.x + 5, self.addressImageV.frame.origin.y + 5 + 25, 25, 25)];
    self.categoryImageV.image = [UIImage imageNamed:@"icon_catalog@2x.png"];
    [self.contentView addSubview:self.categoryImageV];
    [_categoryImageV release];
    
    //类型显示label
    self.category = [[UILabel alloc] initWithFrame:CGRectMake(self.addressImageV.frame.origin.x + self.addressImageV.frame.size.width + 5, self.addressImageV.frame.origin.y + 5 + 25, 230, 25)];
    //self.category.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.category];
    [_category release];
    
    
    self.interested = [[UILabel alloc] initWithFrame:CGRectMake(self.backgroundImagVsmall.frame.origin.x + 15, self.categoryImageV.frame.origin.y + self.categoryImageV.frame.size.height + 20, 60, 20)];
    self.interested.text = @"感兴趣:";
    [self.contentView addSubview:self.interested];
    [_interested release];
    
    self.interestedL = [[UILabel alloc] initWithFrame:CGRectMake(self.interested.frame.origin.x + self.interested.frame.size.width + 5, self.categoryImageV.frame.origin.y + self.categoryImageV.frame.size.height + 20, 60, 20)];
    //self.interestedL.backgroundColor = [UIColor orangeColor];
    self.interestedL.textColor = [UIColor redColor];
    [self.contentView addSubview:self.interestedL];
    [_interestedL release];
    
    self.attend = [[UILabel alloc] initWithFrame:CGRectMake(self.interestedL.frame.origin.x + self.interestedL.frame.size.width + 5, self.categoryImageV.frame.origin.y + self.categoryImageV.frame.size.height + 20, 50, 20)];
    self.attend.text = @"参加:";
    [self.contentView addSubview:self.attend];
    [_attend release];
    
    self.attendL = [[UILabel alloc] initWithFrame:CGRectMake(self.attend.frame.origin.x + self.attend.frame.size.width + 5, self.categoryImageV.frame.origin.y + self.categoryImageV.frame.size.height + 20, 60, 20)];
    //self.attendL.backgroundColor = [UIColor orangeColor];
    self.attendL.textColor = [UIColor redColor];
    [self.contentView addSubview:self.attendL];
    [_attendL release];
    
    
    self.activityImageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.attendL.frame.origin.x + self.attendL.frame.size.width + 20, self.backgroundImagVsmall.frame.origin.y + 10, 90, 130)];
    //self.activityImageV.image = [UIImage imageNamed:@"h4.jpg"];
    [self.contentView addSubview:self.activityImageV];
    [_activityImageV release];
    
}

//- (void)layoutSubviews
//{
//    [super layoutSubviews];
//    self.title.text = @"罗马与巴洛克艺术";
//    self.time.text = @"07-22 09:00--10-16 17:00";
//    self.category.text = @"类型:展览";
//    self.address.text = @"北京 东城区 东长安街16号中国国";
//    self.interestedL.text = @"788";
//    self.attendL.text = @"7884";
//
//}


- (void)setActivity:(Activity *)activity
{
    if (_activity != activity) {
        [_activity release];
        _activity = [activity retain];
    }
    
    self.title.text =  self.activity.title;//@"罗马与巴洛克艺术";
    //self.time.text = @"07-22 09:00--10-16 17:00";
    NSRange range = {5, 11};
    NSString *str1 = [[self.activity.begin_time substringWithRange:range] stringByAppendingString:@"--"];
    NSString *str2 = [self.activity.end_time substringWithRange:range];
    NSString *str = [str1 stringByAppendingString:str2];
    
    self.time.text = str;
    self.category.text = self.activity.category_name;//@"类型:展览";
    self.address.text = self.activity.address;//@"北京 东城区 东长安街16号中国国";
    self.interestedL.text = self.activity.wisher_countt;//@"788";
    self.attendL.text = self.activity.participant_countt;//@"7884";
    //NSString *imge = self.activity.image;
    
    NSURL *url = [NSURL URLWithString:self.activity.image];
    [self.activityImageV sd_setImageWithURL:url placeholderImage:[UIImage imageNamed:@"picholder.png"]];
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
